<template>
	<view>
		<view ref="toast" :style="{height:screenHeight+'px',width:screenWidth + 'px'}" class="fixed-box" v-if="show" @touchmove.stop.prevent="aa">
			<view style="width: 572rpx;background-color: #FFFFFF;border-radius: 16rpx;">
				<view style="padding-top: 46rpx;padding-bottom: 20rpx;">
					<text style="text-align: center;font-size: 34rpx;">{{config.title}}</text>
				</view>

				<view class="flex flex-y fs-28 color-666666"
					style="text-align: left;line-height: 60rpx;padding-left: 50rpx;padding-right: 50rpx;">
					<view class="text" style="word-break: break-all;">
						<text class="fs-28">{{config.desc}}</text>
					</view>
				</view>

				<slot name="center"></slot>

				<view style="padding-top:18rpx" v-if="showBtn">
					<view style="height: 0.5px;background-color: #EEEEEE;"></view>
					<view class="flex">
						<view v-if="config.left" @tap.stop="close_toast(false)"
							style="height: 100rpx;border-right: 0.5px solid #EEEEEE;width:282rpx;"
							class="flex-1 flex flex-x-y fs-44">
							<text style="color: #333333;font-size: 32rpx;">{{config.left}}</text>
						</view>
						<view @tap.stop="close_toast(true)" style="height: 100rpx;width:282rpx;"
							class="flex-1 flex flex-x-y fs-44">
							<text style="color: #FD7747;font-size: 32rpx;">{{config.right}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "toastNvue",
		data() {
			return {
			
				screenHeight:getApp().globalData.screenHeight,
				screenWidth:getApp().globalData.screenWidth,
				
				old_config: {
					title: '提示',
					left: '取消', //左侧文本 不屑就隐藏
					right: '确定', //右侧文本
					success: null,
					fail: null,
					desc: '', //提示内容
				},
				config: {},
				show: false,
			};
		},
		props: {
			close: {
				type: Boolean,
				default: false,
			},
			showBtn: {
				type: Boolean,
				default: true,
			}
		},
		methods: {
			aa(){
				
			},
			open(config = {}) {

				this.config = {
					...this.old_config,
					...config
				};
				// this.$refs.toast.open();
				this.show = true;
			},
			close_toast(status) {
				console.log('status',status)
				// this.$refs.toast.close();
				this.show = false;
				if (status) {
					this.config.success?.();
				} else {
					this.config.fail?.();
				}
			}
		}
	}
</script>

<style lang="scss">
	.color-666666 {
		color: #666666;
	}

	.flex {
		display: flex;
		flex-direction: row;

	}

	.flex-x-y {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	.flex-y {
		flex-direction: column;
	}

	.fixed-box {
		justify-content: center;
		align-items: center;
		position: fixed;
		top: 0;
		z-index: 999999;
	}
</style>
